package object.library;

import object.library.user.Admin;
import object.library.user.NormalUser;
import object.library.user.User;

import java.util.Scanner;

public class Main {

    private static User login() {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入你的姓名：");
        String name = scanner.next();
        System.out.print("请输入你的角色：（1.普通用户 2.管理员）");
        int role = scanner.nextInt();
        if(role == 1){
            return new NormalUser(name);
        }else if(role == 2){
            return new Admin(name);
        }else{
            System.out.println("输入的角色错误！");
            return null;
        }
    }

    public static void main(String[] args) {
        BookList bookList = new BookList();
        User user = login();
        while (true) {
            int choice = user.menu();
            user.work(choice, bookList);
        }
    }
}
